Effective and efficient resource management is a basic computer system requirement, where memory and input/output (I/O) resources should be properly protected to ensure proper computer function without injection of large, performance-sapping overhead. Managing resources safely in a multi-threaded environment is a non-trivial task, especially when access to individual resources is to be protected. A modern computing system may manage millions or more individual resources that are accessed by thousands or more requesters. Thus, proper resource management may be vital to maintaining a high level of system performance.
FIG. 1 depicts an example resource management environment 10. The resource management environment 10 includes a resource pool 12 that contains memory locations, I/O devices, or other resources. The resource management environment 10 also includes a number of operating threads 14, fibers, or other requesters that need to read data from or write data to resources within the resource pool 12. A resource manager 16 may be incorporated within the resource management environment to avoid improper resource contentions and errors that may arise when multiple threads 14 seek to access a resource in the resource pool 12 at the same time. For example, it may be undesirable for a first thread to be permitted to write to a resource, such as a memory location, at the same time that a second thread is reading the same memory location, because the second, reading thread may unknowingly access stale or inconsistent data if the concurrent access is permitted.
FIG. 2 depicts another example resource management environment 20 including a depiction of resources within a resource pool 22. The resource pool includes a number of memory resources 24, labeled 1 to M, that may include both volatile and non-volatile memory locations, registers, as well as other memory resources. In this example, the resource pool 22 may further include a number of I/O resources 26, labeled 1 to N, that may include a multitude of input/output devices and associated read and write buffers including keyboards, pointing devices, display monitors, printers, USB devices, as well as many others. The resource management environment 20 further includes a plurality of threads 28 that seek access to resources of the resource pool. A resource manager 30 is included to manage access to the resource pool 22.
FIG. 3 depicts a prior art resource level lock environment 40 having individual locks 42 associated with each resource 44. A resource manager 46 controls access to a plurality of resources 44. A global lock 48 is used to protect the internal data structures. Each resource 44 has a separate resource lock 42 associated with the resource 44 to protect access to the resource 44.
FIG. 4 depicts a flow diagram illustrating a prior art resource management process 50 that may be used in an environment such as the environment depicted in FIG. 3. As shown at 52, the resource level lock associated with an individual resource 54 to which access is desired is acquired before each access to the resource 54. The individual resource lock is held for the entirety of the access to the resource 54, as depicted at 56. Following completion of access by the requester, the individual resource lock is released, as depicted at 58.